package com.cndongtai.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.cndongtai.dao.BaseDao;
import com.cndongtai.dao.inter.LightFirmwareMapper;
import com.cndongtai.po.LightFirmware;
import com.cndongtai.vo.LightFirmwareBean;

@Repository("lightFirmwareDao")
public class LightFirmwareDao extends BaseDao implements LightFirmwareMapper {

	@Override
	public boolean addLightFirmware(LightFirmware lightFirmware) {
		SqlSession sqlSession = getSqlSession();
		try {
			LightFirmwareMapper operation = sqlSession.getMapper(LightFirmwareMapper.class);
			return operation.addLightFirmware(lightFirmware);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return false;
	}

	@Override
	public boolean updateLightFirmware(LightFirmware lightFirmware) {
		SqlSession sqlSession = getSqlSession();
		try {
			LightFirmwareMapper operation = sqlSession.getMapper(LightFirmwareMapper.class);
			return operation.updateLightFirmware(lightFirmware);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return false;
	}

	@Override
	public LightFirmware queryLightFirmwareByLightId(Integer lightId) {
		SqlSession sqlSession = getSqlSession();
		try {
			LightFirmwareMapper operation = sqlSession.getMapper(LightFirmwareMapper.class);
			return operation.queryLightFirmwareByLightId(lightId);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return null;
	}

	@Override
	public List<LightFirmwareBean> queryLightFirmwareList(Integer userId) {
		SqlSession sqlSession = getSqlSession();
		try {
			LightFirmwareMapper operation = sqlSession.getMapper(LightFirmwareMapper.class);
			return operation.queryLightFirmwareList(userId);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return null;
	}

}
